package com.ruoyi.behindComplaint.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.behindComplaint.domain.DocComplaint;
import com.ruoyi.behindComplaint.service.IDocComplaintService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 投诉处理Controller
 * 
 * @author ruoyi
 * @date 2025-08-15
 */
@RestController
@RequestMapping("/behindComplaint/behindDocComplaint")
public class DocComplaintController extends BaseController
{
    @Autowired
    private IDocComplaintService docComplaintService;

    /**
     * 查询投诉处理列表
     */
    @PreAuthorize("@ss.hasPermi('behindComplaint:behindDocComplaint:list')")
    @GetMapping("/list")
    public TableDataInfo list(DocComplaint docComplaint)
    {
        startPage();
        List<DocComplaint> list = docComplaintService.selectDocComplaintList(docComplaint);
        return getDataTable(list);
    }

    /**
     * 导出投诉处理列表
     */
    @PreAuthorize("@ss.hasPermi('behindComplaint:behindDocComplaint:export')")
    @Log(title = "投诉处理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DocComplaint docComplaint)
    {
        List<DocComplaint> list = docComplaintService.selectDocComplaintList(docComplaint);
        ExcelUtil<DocComplaint> util = new ExcelUtil<DocComplaint>(DocComplaint.class);
        util.exportExcel(response, list, "投诉处理数据");
    }

    /**
     * 获取投诉处理详细信息
     */
    @PreAuthorize("@ss.hasPermi('behindComplaint:behindDocComplaint:query')")
    @GetMapping(value = "/{complaintId}")
    public AjaxResult getInfo(@PathVariable("complaintId") Long complaintId)
    {
        return success(docComplaintService.selectDocComplaintByComplaintId(complaintId));
    }

    /**
     * 新增投诉处理
     */
    @PreAuthorize("@ss.hasPermi('behindComplaint:behindDocComplaint:add')")
    @Log(title = "投诉处理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DocComplaint docComplaint)
    {
        return toAjax(docComplaintService.insertDocComplaint(docComplaint));
    }

    /**
     * 修改投诉处理
     */
    @PreAuthorize("@ss.hasPermi('behindComplaint:behindDocComplaint:edit')")
    @Log(title = "投诉处理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DocComplaint docComplaint)
    {
        return toAjax(docComplaintService.updateDocComplaint(docComplaint));
    }

    /**
     * 删除投诉处理
     */
    @PreAuthorize("@ss.hasPermi('behindComplaint:behindDocComplaint:remove')")
    @Log(title = "投诉处理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{complaintIds}")
    public AjaxResult remove(@PathVariable Long[] complaintIds)
    {
        return toAjax(docComplaintService.deleteDocComplaintByComplaintIds(complaintIds));
    }
}
